package com.neusoft.servlet;

import com.alibaba.fastjson.JSON;
import com.neusoft.model.UserInfo;
import org.apache.commons.io.IOUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/api/articlesxxx")
public class HelloServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        Integer limit = Integer.parseInt(req.getParameter("limit"));
//        Integer offset = Integer.parseInt(req.getParameter("offset"));
//        String tag = req.getParameter("tagxx");
//        String author = req.getParameter("author");
////        System.out.println(limit);
////        System.out.println(offset);
//        System.out.println(tag);
//        System.out.println(author);
//        PrintWriter writer = resp.getWriter();
//        writer.println(tag+author);
        System.out.println("xxxxxxxxxxxxxxxxxxxxxxxx");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String jsonReq = IOUtils.toString(req.getInputStream());
        UserInfo userInfo = JSON.parseObject(jsonReq, UserInfo.class);
        System.out.println(userInfo);
        PrintWriter writer = resp.getWriter();
        writer.println(userInfo);
    }
}
